<?php

class Perfil extends CI_Controller {

    function Perfil() {
        parent::__construct();
		$this->load->model('ws/usuario_model');
        session_start();
        if (!$this->session->userdata('logged_in')) {
            $this->session->set_flashdata('error', 'Debe haberse logueado');
            redirect('login', 'refresh');
        }
    }
	
	public function index() {
		$data['map'] = null;
		$data['title'] = "Mi Perfil";
        $data['username'] = $this->session->userdata('username');
        $data['name'] = $this->session->userdata('name');
        $data['acceso'] = $this->session->userdata('acceso');
		$idUsuario = $this->session->userdata('id_contact');
        $data['main'] = "pages/dashboard_user.php"; //Ruta del contenido del home
		
		$data['user'] = $this->usuario_model->get_user_by_id($idUsuario);
		
        $this->load->vars($data);
		$this->load->view('user_views/dashboard_user_view');
	}
	
	public function user($idUsuario){
		
		$data['map'] = null;
		$data['title'] = "Mi Perfil";
        $data['username'] = $this->session->userdata('username');
        $data['name'] = $this->session->userdata('name');
        $data['acceso'] = $this->session->userdata('acceso');
        $data['main'] = "pages/dashboard_user.php"; //Ruta del contenido del home
		
		$data['user'] = $this->usuario_model->get_user_by_id($idUsuario);
		
        $this->load->vars($data);
		$this->load->view('user_views/dashboard_user_view');
	
	}	

    function logout() {
        $this->session->sess_destroy();
        $this->session->unset_userdata('logged_in');
        $this->session->set_flashdata('error', "Usted ha sido deslogueado!");
        redirect('login', 'refresh');
    }

}

?>
